import sys
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QFormLayout, QLineEdit


edit_name : QLineEdit = None
edit_age : QLineEdit = None
edit_phone : QLineEdit = None

def on_submit():
    # print("提交")
    print("姓名: ", edit_name.text())
    print("年龄：", edit_age.text())
    print("电话: ", edit_phone.text())

def init_widget(w:QWidget):
    w.setWindowTitle("表单布局")
    # w.resize(640, 480)
    layout = QFormLayout(w)
    
    global edit_name, edit_age, edit_phone
    
    edit_name = QLineEdit()
    edit_age = QLineEdit()
    edit_phone = QLineEdit()
    layout.addRow("姓名:", edit_name)
    layout.addRow("年龄:", edit_age)
    layout.addRow("电话:", edit_phone)
    
    btn_submit = QPushButton("提交")
    btn_submit.clicked.connect(on_submit)
    
    layout.addRow(" ", btn_submit)
    
if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = QWidget()
    init_widget(w)
    w.show()
    sys.exit(app.exec_())
    